package codepulse.blogmoon.cn.common.entity;


import codepulse.blogmoon.cn.common.context.Context;
import codepulse.blogmoon.cn.common.enums.DeleteEnum;
import lombok.Data;

import java.io.Serializable;
import java.util.Date;

@Data
public class BaseEntity implements Serializable {

    private static final long serialVersionUID = 1L;

    /**
     * 创建人
     */
    private Long created;

    /**
     * 创建时间
     */
    private Date createTime;

    /**
     * 修改人
     */
    private Long modifier;

    /**
     * 修改时间
     */
    private Date modifyTime;

    /**
     * 软删
     */
    private Integer deleted;

    public void setCreateField() {
        Date date = new Date();
        this.created = Context.get().getBizAcctId();
        this.createTime = date;
        this.modifier = Context.get().getBizAcctId();
        this.modifyTime = date;
        this.deleted = DeleteEnum.NOT_DELETE.getCode();
    }

    public void setModifyField() {
        this.modifier = Context.get().getBizAcctId();
        this.modifyTime = new Date();
        this.deleted = DeleteEnum.NOT_DELETE.getCode();
    }

}

